package com.eveinfo.api.character.list;

import java.io.IOException;

import javax.xml.parsers.ParserConfigurationException;

import org.xml.sax.SAXException;

import com.eveinfo.api.AbstractApiParser;
import com.eveinfo.api.ApiAuth;
import com.eveinfo.api.ApiException;
import com.eveinfo.api.NoCacheFoundExecption;

public class CharacterListParser extends AbstractApiParser<CharacterListResponse,CharacterListHandler> {
	
	private static final String CHARACTER_LIST_URL = "/account/Characters.xml.aspx";
	
	private static CharacterListParser instance;
	
	public static CharacterListParser getInstance(){
		if(instance == null){
			instance = new CharacterListParser();
		}
		return instance;
	}
	
	private CharacterListParser() {
		super(CharacterListResponse.class, 1, CHARACTER_LIST_URL);
	}

	public CharacterListResponse getEveCharacters(ApiAuth auth) throws IOException,
			SAXException, ParserConfigurationException, ApiException, NoCacheFoundExecption {
		CharacterListHandler handler = new CharacterListHandler();
		return getResponse(auth, handler);
	}

	public static boolean isInstancier() {
		return instance != null;
	}
}